import java.util.Random;
import java.util.Scanner;
public class GuessGame {

    public static void End(int secret, int guess){
        if(secret==guess)
            System.out.print("Congrats, you won!");
        else
            System.out.print("Sorry, you lost.  My number was "+secret);
    }

    public static void main(String[] args) {
        System.out.print("Guess my number! It is between 1 and 30. Enter your guess to the right.");
        int guess=0;
        Random r = new Random();
        int secret=r.nextInt(30) +1;
        int i=0;
        while(guess!=secret||i==3){
            i++;
            Scanner input= new Scanner(System.in);
            guess=input.nextInt();
            if(guess>secret)
                System.out.print("Your guess is too high. Try again");
            else if(guess<secret)
                System.out.print("Your guess is too low. Try again");
            }
        End(secret,guess);
        }
        //    Lastguess(secret,guess);
        }
           // End(secret,guess);



